<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue 学习 1-3</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <h2>列表渲染</h2>
    <!-- 用 v-for 把一个数组对应为一组元素 -->
    <ul id="example-1">
        <li v-for="(item,index) in items">
            {{ parentMessage }} - {{ index }} - {{ item.message }}
        </li>
    </ul>
    <!-- 在 v-for 里使用对象 -->
    <ul id="v-for-object" class="demo">
        <li v-for="(value,name,index) in object">
            {{ index }}-{{ name }} - {{ value }}
        </li>
    </ul>
</body>

<script>
    var example1 = new Vue({
        el: '#example-1',
        data: {
            parentMessage: 'parent',
            items: [
                { message: 'Foo' },
                { message: 'Bar' }
            ]
        }
    })
    new Vue({
        el: "#v-for-object",
        data: {
            object: {
                name: "姓名",
                age: "12",
                addrss: "德商华府天骄"
            }
        }
    })
</script>

</html>